#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>

using namespace std;
const int mod = 1e9+7;

long long n, m;
// n%1+n%2+n%3+...+n%i = n*i-(n/1*1+n/2*2+n/3*3+...+n/i*i) i<=n;
int val[1001000];

long long cal(long long a,long long b){
    long long rev = 0;
    rev += ((a%mod)*((a-b)%mod))%mod;


}
int main(int argc, char **argv){
    long long ans = 0;
    if(n<m){
        ans+=((m%mod)*((m-n)%mod))%mod;
    }
    ans+=cal(n,min(m,n));
    cout << ans%mod << endl;
    return 0;
}
